/**
 * Copyright (c) 2013-Now http://aidex.vip All rights reserved.
 */
// 此处第二个参数vm，就是我们在页面使用的this，你可以通过vm获取vuex等操作
const install = (Vue, vm) => {

	// 参数配置对象
	const config = vm.vuex_config;

	// 将各个定义的接口名称，统一放进对象挂载到vm.$u.api(因为vm就是this，也即this.$u.api)下
	vm.$u.api = {

		// 基础服务：登录登出、身份信息、菜单授权、切换系统、字典数据等
		lang: (params = {}) => vm.$u.get('/lang/' + params.lang),
		getUserInfo: (params = {}) => vm.$u.get(config.adminPath + '/getInfo', params),
		getRouters: (params = {}) => vm.$u.get(config.adminPath + '/getRouters', params),
		login: (params = {}) => vm.$u.post(config.adminPath + '/login', params),
		logout: (params = {}) => vm.$u.get(config.adminPath + '/logout', params),
		updatePwd: (params = {}) => vm.$u.put(config.adminPath + `/system/user/profile/updatePwd?oldPassword=${params.oldPassword}&newPassword=${params.newPassword}`, params),
		updateAvatar: (params = {}) => vm.$u.post(config.adminPath + '/system/user/profile/avatar', params),
		sendCode: (params = {}) => vm.$u.post(config.adminPath + '/mobile/login/sendCode', params),
		registerUser: (params = {}) => vm.$u.post(config.adminPath + '/mobile/user/registerUser', params),
		//工单申请相关api
		// 凭证类型
		voucherTypeList: (params = {}) => vm.$u.get(config.adminPath + '/business/voucherType/listNoPage', params),
		// 行政区划
		mofdivList: (params = {}) => vm.$u.get(config.adminPath + '/business/mofdiv/listNoPage', params),
		//单位名称
		deptTree: (params = {}) => vm.$u.get(config.adminPath + '/business/businessOrder/deptTree', params),
		// 新增工单
		addBusinessOrder: (params = {}) => vm.$u.post(config.adminPath + '/business/businessOrder', params),
		// 修改工单
		updateBusinessOrder: (params = {}) => vm.$u.put(config.adminPath + '/business/businessOrder', params),
		// 工单送审
		completeBusinessOrder: (params = {}) => vm.$u.post(config.adminPath + '/business/businessOrder/complete', params),
		// 审核
		completeContent: (params = {}) => vm.$u.post(config.adminPath + '/business/businessOrder/completeContent', params),
		// 回退
		returnOrder: (params = {}) => vm.$u.post(config.adminPath + '/business/businessOrder/return', params),
		// 获取审核用户
		nextFlowNode: (params = {}) => vm.$u.post(config.adminPath + '/business/businessOrder/nextFlowNode', params),
		// 获取回退节点
		returnList: (params = {}) => vm.$u.post(config.adminPath + '/business/businessOrder/returnList', params),
		//删除工单
		delBusinessOrder: (id) => vm.$u.delete(config.adminPath + `/business/businessOrder/${id}`),
		//工单详细
		getBusinessOrder: (id) => vm.$u.get(config.adminPath + `/business/businessOrder/${id}`),
		// 流转记录
		flowRecord: (params = {}) => vm.$u.get(config.adminPath + '/business/businessOrder/flowRecord', params),
		// 待办列表
		BusinessOrderTodoList: (params = {}) => vm.$u.get(config.adminPath + '/business/businessOrder/todoList', params),
		listByOnwer: (params = {}) => vm.$u.get(config.adminPath + '/business/businessOrder/listByOnwer', params),
		listByOperation: (params = {}) => vm.$u.get(config.adminPath + '/business/businessOrder/listByOperation', params),
		listAll: (params = {}) => vm.$u.get(config.adminPath + '/business/businessOrder/list', params),

		// 首页相关api
		// 新增反馈
		addFeeback: (params = {}) => vm.$u.post(config.adminPath + '/business/app/addFeeback', params),
		// 已读
		clickTask: (params = {}) => vm.$u.get(config.adminPath + '/business/app/clickTask', params),
		// 查看
		getNoticeById: (params = {}) => vm.$u.get(config.adminPath + '/business/app/getNoticeById', params),
		getMenus: (params = {}) => vm.$u.get(config.adminPath + '/business/app/getRouters', params),
		getHome: (params = {}) => vm.$u.get(config.adminPath + '/business/app/home', params),
		getHomeCount: (params = {}) => vm.$u.get(config.adminPath + '/business/app/homeCount', params),
		getNewsList: (params = {}) => vm.$u.get(config.adminPath + '/business/app/homeNewsList', params),
		getNoticeCount: (params = {}) => vm.$u.get(config.adminPath + '/business/app/homeNoticeList', params),
		getTaskCount: (params = {}) => vm.$u.get(config.adminPath + '/business/app/homeTaskList', params),


		// 根据字典类型查询字典数据信息
		getDicts: (dictType) => vm.$u.get(config.adminPath + `/system/dict/data/type/${dictType}`),

		authInfo: (params = {}) => vm.$u.get(config.adminPath + '/authInfo', params),
		menuTree: (params = {}) => vm.$u.get(config.adminPath + '/menuTree', params),
		switchSys: (params = {}) => vm.$u.get(config.adminPath + '/switch/' + params.sysCode),
		dictData: (params = {}) => vm.$u.get(config.adminPath + '/system/dict/data/type/' + params.dictType),

		// 账号服务：验证码接口、忘记密码接口、注册账号接口等
		validCode: (params = {}) => vm.$u.getText('/validCode', params),
		getFpValidCode: (params = {}) => vm.$u.post('/account/getFpValidCode', params),
		savePwdByValidCode: (params = {}) => vm.$u.post('/account/savePwdByValidCode', params),
		getRegValidCode: (params = {}) => vm.$u.post('/account/getRegValidCode', params),
		saveRegByValidCode: (params = {}) => vm.$u.post('/account/saveRegByValidCode', params),

		// APP公共服务
		upgradeCheck: () => vm.$u.post('/app/upgrade/check', { appCode: config.appCode, appVersion: config.appVersion }),
		commentSave: (params = {}) => vm.$u.post('/app/comment/save', params),

		// 个人信息修改
		user: {
			saveUserInfo: (params = {}) => vm.$u.post(config.adminPath + '/mobile/user/saveUserInfo', params),
			infoSavePwd: (params = {}) => vm.$u.put(config.adminPath + `/system/user/profile/updatePwd?oldPassword=${params.oldPassword}&newPassword=${params.newPassword}`, params),
			infoSavePqa: (params = {}) => vm.$u.post(config.adminPath + '/sys/user/infoSavePqa', params),
		},

		// 员工用户查询
		empUser: {
			listData: (params = {}) => vm.$u.get(config.adminPath + '/sys/empUser/listData', params),
		},

		// 组织机构查询
		office: {
			treeData: (params = {}) => vm.$u.get(config.adminPath + '/sys/office/treeData', params),
		},

		// 增删改查例子
		testData: {
			form: (params = {}) => vm.$u.post(config.adminPath + '/test/testData/form', params),
			list: (params = {}) => vm.$u.post(config.adminPath + '/test/testData/listData', params),
			save: (params = {}) => vm.$u.postJson(config.adminPath + '/test/testData/save', params),
			disable: (params = {}) => vm.$u.post(config.adminPath + '/test/testData/disable', params),
			enable: (params = {}) => vm.$u.post(config.adminPath + '/test/testData/enable', params),
			delete: (params = {}) => vm.$u.post(config.adminPath + '/test/testData/delete', params),
		},

	};

}

export default {
	install
}